package com.sharp.authorization.controller;

import com.sharp.authorization.service.area.AreaService;
import com.sharp.authorization.vo.area.AreaInfoRes;
import com.sharp.kernel.config.response.Response;
import com.sharp.kernel.config.response.ResponseHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Title: AreaController
 * Description: Copyright: Copyright (c) 2019 Company: BHFAE
 *
 * @author Sharp
 * @date 2020/5/1 15:05
 * @description Project Name: Seed
 * @Package: com.srct.service.account.controller
 */
@Api(value = "行政区域信息", tags = "行政区域信息")
@RestController("AreaController")
@RequestMapping(value = "/area")
public class AreaController {

    @Resource
    private AreaService areaService;

    @ApiOperation(value = "行政区域信息", notes = "行政区域信息")
    @RequestMapping(value = "", method = RequestMethod.GET)
    public ResponseEntity<Response<List<AreaInfoRes>>> areaInfo(
            @RequestParam(required = false) String parentCode) {
        List<AreaInfoRes> res = areaService.getAreaInfo(parentCode);
        return ResponseHandler.generateResponse(res);
    }
}
